//
//  SEGShareImageBottomView.m
//  SEGUhomeStandard
//
//  Created by 揭婧雯 on 2018/10/24.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import "SEGShareImageBottomView.h"
@interface SEGShareImageBottomView ()

@property (nonatomic, strong) UIButton *appLogoButton;
@property (nonatomic, strong) UILabel *appNameLabel;
@property (nonatomic, strong) UILabel *subNameLabel;
@property (nonatomic, strong) UIImageView *qrCodeImageView;

@end


@implementation SEGShareImageBottomView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self setUpUI];
    }
    return self;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self setUpUI];
    }
    return self;
}

- (void)setUpUI
{
    UIView *separator = [[UIView alloc] init];
    [self addSubview:separator];
    separator.backgroundColor = kColor_3;
    [separator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.right.equalTo(self).offset(-10);
        make.top.equalTo(self);
        make.height.mas_equalTo(0.5);
    }];
    
    [self.appLogoButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self).offset(10);
        make.centerY.equalTo(self);
    }];
    [self.appNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.appLogoButton.mas_right).offset(5);
        make.top.equalTo(self.appLogoButton).offset(0);
    }];
    [self.subNameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.appNameLabel);
        make.top.equalTo(self.appNameLabel.mas_bottom).offset(5);
    }];
    [self.qrCodeImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self).offset(-10);
        make.centerY.equalTo(self);
        make.width.height.mas_equalTo(50);
    }];
}

- (void)setQrCodeImage:(UIImage *)qrCodeImage
{
    self.qrCodeImageView.image = qrCodeImage;
}

#pragma mark - getter
- (UIButton *)appLogoButton {
    if (!_appLogoButton) {
        _appLogoButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_appLogoButton setImage:[UIImage imageWithContentsOfFile:SEGPicName(@"icon_huati_share_logo")] forState:UIControlStateNormal];
        //[_appLogoButton setTitle:@"" forState:UIControlStateNormal];
        [_appLogoButton setTitleColor:kColor_3 forState:UIControlStateNormal];
        _appLogoButton.titleLabel.font = [UIFont systemFontOfSize:11];
        //_appLogoButton.titleEdgeInsets = UIEdgeInsetsMake(0, 3, 0, -3);
        [self addSubview:_appLogoButton];
    }
    return _appLogoButton;
}
- (UILabel *)appNameLabel {
    if (!_appNameLabel) {
        _appNameLabel = [[UILabel alloc] init];
        [self addSubview:_appNameLabel];
        _appNameLabel.text = kAppName;
        _appNameLabel.font = [UIFont systemFontOfSize:13];
        _appNameLabel.textColor = kColor_1;
    }
    return _appNameLabel;
}
- (UILabel *)subNameLabel {
    if (!_subNameLabel) {
        _subNameLabel = [[UILabel alloc] init];
        [self addSubview:_subNameLabel];
        _subNameLabel.text = @"发现生活无限可能";
        _subNameLabel.font = [UIFont systemFontOfSize:11];
        _subNameLabel.textColor = kColor_3;
    }
    return _subNameLabel;
}
- (UIImageView *)qrCodeImageView {
    if (!_qrCodeImageView) {
        _qrCodeImageView = [[UIImageView alloc] init];
        [self addSubview:_qrCodeImageView];
    }
    return _qrCodeImageView;
}

@end
